package com.hdphone.zljutils.inter;

import android.annotation.TargetApi;
import android.app.Activity;
import android.os.Build;
import android.view.View;

/**
 * @date: 2021/6/2
 * @email： yzandlj@163.com
 * @author： yangzhi
 * @describe: 软键盘工具类
 */
public interface IKeyboardUtil {


    /**
     * Show the soft input.
     *
     * @param activity The activity.
     */
    void showSoftInput(Activity activity);

    /**
     * Show the soft input.
     *
     * @param activity The activity.
     * @param flags    Provides additional operating flags.  Currently may be
     *                 0 or have the {@link InputMethodManager#SHOW_IMPLICIT} bit set.
     */
    void showSoftInput(final Activity activity, final int flags);

    /**
     * Show the soft input.
     *
     * @param view The view.
     */
    void showSoftInput(final View view);

    /**
     * Show the soft input.
     *
     * @param view  The view.
     * @param flags Provides additional operating flags.  Currently may be
     *              0 or have the {@link InputMethodManager#SHOW_IMPLICIT} bit set.
     */
    void showSoftInput(final View view, final int flags);

    /**
     * Hide the soft input.
     *
     * @param activity The activity.
     */
    void hideSoftInput(final Activity activity);

    /**
     * Hide the soft input.
     *
     * @param view The view.
     */
    void hideSoftInput(final View view);

    /**
     * Toggle the soft input display or not.
     */
    void toggleSoftInput();

    /**
     * Return whether soft input is visible.
     *
     * @param activity The activity.
     * @return {@code true}: yes<br>{@code false}: no
     */
    boolean isSoftInputVisible(final Activity activity);


    /**
     * Register soft input changed listener.
     *
     * @param activity The activity.
     * @param listener The soft input changed listener.
     */
    void registerSoftInputChangedListener(final Activity activity,
                                          final OnSoftInputChangedListener listener);

    /**
     * Unregister soft input changed listener.
     *
     * @param activity The activity.
     */
    @TargetApi(Build.VERSION_CODES.JELLY_BEAN)
    void unregisterSoftInputChangedListener(final Activity activity);


    interface OnSoftInputChangedListener {
        void onSoftInputChanged(int height);
    }
}
